import { ConfigType, registerAs } from '@nestjs/config'
import { env, envBoolean } from '../common/global/env'

export const swaggerRegToken = 'swagger'

export const SwaggerConfig = registerAs(swaggerRegToken, () => ({
  enable: envBoolean('SWAGGER_ENABLE'),
  path: env('SWAGGER_PATH'),
}))

export type ISwaggerConfig = ConfigType<typeof SwaggerConfig>

export default (): { swagger: ISwaggerConfig } => ({
  swagger: {
    enable: process.env.SWAGGER_ENABLE === 'true',
    path: process.env.SWAGGER_PATH || 'api-docs',
  },
});
